package HouseTest.Ui;

import HouseTest.Service.HouseService;
import HouseTest.javaBean.Admin;

import java.io.IOException;
import java.util.Scanner;

public class AdminDemo {
    public static void main(String[] args) throws IOException {
        while (true){
            HouseService hs = new HouseService();
            Scanner scanner=new  Scanner(System.in);
            System.out.println("输入用户名");
            String user=scanner.next();
            System.out.println("输入密码");
            String password=scanner.next();
            Admin admin1=new Admin();
            admin1.setUser(user);
            admin1.setPassword(password);
            //登录验证
            if (hs.adminBoolean(admin1)) {
                // 判断用户输入的验证码是否正确
                int i = hs.CaptchaLogin();
                System.out.println("请输入验证码：");
                int userInput = scanner.nextInt();
                if (userInput == i) {
                    System.out.println("验证码正确，登录成功！");
                } else {
                    System.out.println("验证码错误，请重试！");
                    continue;
                }
                HouseView.mainMenu();
                break;
            }else {
                System.out.println("用户名或密码错误，请重试(退出：N)");
               char N=scanner.next().charAt(0);
                if(N=='N'){
                   break;
                }
            }
        }
    }
}
